package scu.maqiang.meshgeneration;

import scu.maqiang.mesh.Mesh3T4;
import scu.maqiang.mesh.MeshFormat;

public class PeriodicMesh3D {

	public static void main(String[] args) {
		String dir = "MeshFile\\";
		String meshFile = dir + "CCubeHoleCompo.mesh";
		Mesh3T4 mesh3D = new Mesh3T4().readMesh(meshFile, MeshFormat.mesh);
		String outputDir = "MeshGeneration\\";
		System.out.println("Initial Mesh Information: ");
		System.out.println("Nv: " + mesh3D.getNv() + "\t Nt: " + mesh3D.getNt() + "\t Nb: " + mesh3D.getNb());
		
		//Mesh3T4 mesh3D2 = mg.readMesh(meshFile, MeshFormat.mesh);
		//mesh3D2.translate(1.0, 0.0, 0.0);
		
		//mesh3D.add(mesh3D2);
		//mesh3D.toTecplot(outputDir + "CCubeHoleCompo2.dat");
		
//		System.out.println("Adding one mesh: ");
//		System.out.println("Nv: " + mesh3D.getNv() + "\t Nt: " + mesh3D.getNt() + "\t Nb: " + mesh3D.getNb());
		
		int n = 8;
		for (int i = 1; i < n; i++) {
			Mesh3T4 mesh3D2 = new Mesh3T4().readMesh(meshFile, MeshFormat.mesh);
			mesh3D2.translate(i * 1.0, 0.0, 0.0);
			mesh3D.add(mesh3D2);
			System.out.println("Adding one mesh: ");
			System.out.println("Nv: " + mesh3D.getNv() + "\t Nt: " + mesh3D.getNt() + "\t Nb: " + mesh3D.getNb());
			System.gc();
		}
//		mesh3D.toTecplot(outputDir + "CCubeHoleCompo8.dat");
		String meshFile8 = outputDir + "HoleCompo8.msh";
		mesh3D.saveMesh(MeshFormat.msh, meshFile8);
		
		for (int i = 1; i < n; i++) {
			Mesh3T4 mesh3D2 = new Mesh3T4().readMesh(meshFile8, MeshFormat.msh);
			mesh3D2.translate(0.0, i * 1.0, 0.0);
			mesh3D.add(mesh3D2);
			System.out.println("Adding one mesh: ");
			System.out.println("Nv: " + mesh3D.getNv() + "\t Nt: " + mesh3D.getNt() + "\t Nb: " + mesh3D.getNb());
			System.gc();
		}
		//mesh3D.toTecplot(outputDir + "CCubeHoleCompo64.dat");
		
		String meshFile64 = outputDir + "HoleCompo64.msh";
		mesh3D.saveMesh(MeshFormat.msh, meshFile64);
		
		for (int i = 1; i < n; i++) {
			Mesh3T4 mesh3D2 = new Mesh3T4().readMesh(meshFile64, MeshFormat.msh);
			mesh3D2.translate(0.0, 0.0, 1.0 * i);
			mesh3D.add(mesh3D2);
			System.out.println("Adding one mesh: ");
			System.out.println("Nv: " + mesh3D.getNv() + "\t Nt: " + mesh3D.getNt() + "\t Nb: " + mesh3D.getNb());
			System.gc();
		}
		mesh3D.toTecplot(outputDir +"HoleCompo5122.dat");
		mesh3D.saveMesh(MeshFormat.msh, outputDir +"HoleCompo5122.msh");
	}
	
	

}
